
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>DataType.Date.format()</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>


<!--begin custom header content for this example-->
<style type="text/css">
/* custom styles for this example */
#demo .output {margin-bottom:1em; padding:10px; border:1px solid #D9D9D9;}
</style>

</style>

<!--end custom header content for this example-->

</head>

<body class=" yui-skin-sam">

<h1>DataType.Date.format()</h1>

<div class="exampleIntro">
	The Date module of the DataType Utility allows you to format a JavaScript Date object into a string with <code>strftime</code> syntax.
			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<form id="demo">
    <fieldset>
        <label for="demo_format">Format (optional):</label>
        <input type="text" id="demo_format" value="%r">
        <label for="demo_locale">Locale (optional):</label>
        <input type="text" id="demo_locale" value="en-GB">
        <input type="button" id="demo_btn" value="Format current date =>">
        <div id="demo_output" class="output"></div>
    </fieldset>
</form>



<script type="text/javascript">
YUI({base:"../../build/", timeout: 10000}).use("node", "datatype-date", function (Y) {
    Y.on("click", function(e){
        var date = new Date(),
            output = Y.DataType.Date.format(date, {format:Y.get("#demo_format").get("value"), locale:Y.get("#demo_locale").get("value")});

        if(output === "") {
            output += "(Invalid input)"
        }
        Y.get("#demo_output").setContent(output.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"));
    }, "#demo_btn");
});
</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>
